﻿using com.guojin.mj.net.message.club;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;


public class ClubPlayerListItemPage : MonoBehaviour {

    public RawImage headImg;
    private int playerId;
    public Text playerName;
    public Text playerState;

    IEnumerator SHImageDownload(string url)
    {
        if (url == null || url == "")
        {
            url = URLConst.DefaultUserHeadUrl;
        }
        //url = url.Substring(0, url.Length - 1);     //这里对头像进行处理
        //url += "132";
        WWW www = new WWW(url);
        yield return www;
        headImg.texture = www.texture;
    }

    public void SetMsg(ClubPlayerStateChange cpi)
    {
        StartCoroutine(SHImageDownload(cpi.Avatar));
        playerId = cpi.Id;
        playerName.text = cpi.Name;
        SetPlayerState(cpi.State);
    }

    // 1离线 2等待 3游戏中
   public void SetPlayerState(int state)
   {
       Debug.Log(state);
        switch (state)
        {
            case 1:
                playerState.text = "<color=grey>离线</color>";
                break;
            case 2:
                playerState.text = "<color=green>等待</color>";
                break;
            case 3:
                playerState.text = "<color=red>游戏中</color>";
                break;
            default:
                break;
        }
    }

    void Update () {	
	}
}
